<template>
  <block v-for="(item,index) in list" :key="item.id">
    <house-item :item="item" customStyle="background:#fff;margin:20rpx" :imageWidth="234" imageHeight="192"
      :page="`/pages/index/houseHot/articleDetail?id=${item.id}`">
      <template #right>
        <view class="u-flex-between u-flex-column u-flex-fill">
          <view class="house-name ">
            {{item.title}}
          </view>s
          <view class="house-user u-flex-between u-flex-y-center ">
            <view class="u-flex-y-center">
              <image :src="prefixURL(item.user.avatar)" class="house-avatar" mode=""></image>
              <text>{{item.user.nickname}}</text>
            </view>
            <view class="u-flex-y-center">
              <image src="@/static/images/01_32hk.png" class="house-icon" mode=""></image>
              <text>{{item.likes}}</text>
            </view>
          </view>
        </view>
      </template>
    </house-item>
  </block>
</template>

<script setup>
  import { onMounted, ref } from 'vue';
  import houseItem from '@/components/house-item/house-item.vue';
  import { articleList } from '../../../config/api';
  import { onReachBottom } from '@dcloudio/uni-app'
  import { prefixURL } from '../../../util/util';
  const params = ref({
    page: 1,
    limit: 15,
    category_id: 21
  })
  const list = ref([])
  onMounted(() => {
    _articleList()
  })
  onReachBottom(() => {
    params.value.page++
    _articleList()
  })
  // 文章列表
  const _articleList = () => {
    articleList(params.value).then(res => {
      if (params.value.page == 1) list.value = res.data.data
      else list.value = list.value.concat(res.data.data)
    })
  }
</script>

<style scoped lang="scss">
  .house-user {
    font-size: 26rpx;
    color: #333;
    font-weight: 500;

    .house-avatar {
      width: 54rpx;
      height: 54rpx;
      border-radius: 50%;
      margin-right: 10rpx;
    }

    .house-icon {
      width: 24rpx;
      margin-right: 10rpx;
      height: 34rpx;
    }
  }
</style>